<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="ReportTasks.aspx.cs" Inherits="ReportTasks" Title="ABC SuperSign - Users" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<%@ Register Assembly="Microsoft.Web.Preview" Namespace="Microsoft.Web.Preview.UI.Controls" TagPrefix="cc2" %>
<%@ Register Src="UserAccess.ascx" TagName="UserAccess" TagPrefix="uc1" %>
<%@ Register Src="GlobalAjax.ascx" TagName="GlobalAjax" TagPrefix="uc2" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder_Main" Runat="Server">
<form action="#" runat="server">
<asp:ScriptManager ID="ScriptManager_Tasks" runat="server">
</asp:ScriptManager>
<uc1:UserAccess ID="UserAccess1" runat="server" />
<uc2:GlobalAjax ID="ctl_GlobalAjax" runat="server" />
<asp:HiddenField ID="ExportFileName" runat="server" Value="" />

<!-- page title start -->
<h1>
	<span>Reporting: Tasks</span>
</h1>
<!-- page title end -->
<!-- Main Content start -->
<div class="mainHolder"> 
<!-- left block start -->
	<div class="leftBlock">
	    <h2>
	    <span>Report Parameters</span>
        </h2>
	    <div class="innerBlock collapsed">
	    <h3>
			<span>Search Assets</span>
			<a href="#" class="switch">Open/Collapse</a>
		</h3>
			<div class="innerContent">
                <div id="assetSearchFields"></div>
	            <div id="assetSearchButtons" class="row" style="display:none;">
                    <asp:Button ID="Btn_Search" runat="server" Text="Search" OnClick="Btn_Search_Click" OnClientClick="prepareSearch(); $('reportParameters').removeClassName('collapsed');" />
                    <div class="spacerS"></div>
                    <input id="assetReset" type="button" value="Reset" onclick="resetSearchFields('assetSearchFields');"/>
                </div>
            </div>
        </div>
        <div id="reportParameters" class="innerBlock">
	    <h3>
		    <span>Report Parameters</span>
		    <a href="#" class="switch">Open/Collapse</a>
	    </h3>
            <div class="innerContent">
                <asp:UpdatePanel ID="UpdatePanel_Search" runat="server" UpdateMode="Conditional">
                <Triggers>
                <asp:AsyncPostBackTrigger ControlID="Btn_Search" EventName="Click" />
                </Triggers>
                <ContentTemplate>
                    <div class="row">
                        <label>Task Type</label>
                        <asp:DropDownList id="DDList_TaskTypes" runat="server" CssClass="widthM"></asp:DropDownList>
                    </div>
                    <div class="row">
                        <label>User</label>
                        <asp:DropDownList id="DDList_Users" CssClass="widthM" runat="server"></asp:DropDownList>
                    </div>
                    <div class="row">
				        <div class="col">
			                <label>Task Due Date Range</label>
                            <asp:TextBox ID="TextBox_DateFrom" runat="server" CssClass="aspDateBox"></asp:TextBox>
		                    <span>to</span>
                            <asp:TextBox ID="TextBox_DateTo" runat="server" CssClass="aspDateBox"></asp:TextBox>
				        </div>
			        </div>
                    <div class="row">
                        <label>Select Asset</label>
                        <asp:ListBox ID="ListBox_Results" runat="server" CssClass="heightS widthM"></asp:ListBox>                    
	                </div>
			        <div class="row">
                        <asp:Button ID="Btn_RunReport" runat="server" Text="Run Report" OnClick="Btn_RunReport_Click" OnClientClick="showProgress();" />
                        <div class="spacerS"></div>
                    <asp:Button ID="Btn_Reset" runat="server" Text="Reset" OnClick="Btn_Reset_Click" />
                    </div>
                </ContentTemplate>
                </asp:UpdatePanel> 
            </div>
	    </div>
	</div>
<!-- left block end -->
<!-- right block start -->
    <div class="rightBlock">
        <asp:UpdatePanel ID="UpdatePanel_Results" runat="server">
            <ContentTemplate>
                <h2>
                    <span>Results</span>
                    <asp:Button ID="Btn_ExportCSV" runat="server" Text="Export" CssClass="aspButton"
                        Enabled="false" OnClick="Btn_ExportCSV_Click" />
                    <asp:Button ID="Btn_Print" runat="server" Text="Print" CssClass="aspButton" Enabled="false" />
                </h2>
                <div class="innerContent" style="padding-bottom: 10px;">
                    <asp:Label ID="Lbl_Messages" runat="server" Text=""></asp:Label>
                    <div class="reportResults">
                        <asp:GridView ID="GridView_Results" runat="server" CellPadding="4" GridLines="None" ShowFooter="True">
                            <HeaderStyle Font-Size="13px" />
                            <FooterStyle Font-Bold="True" Font-Size="13px" />
                        </asp:GridView>
                    </div>
                </div>
            </ContentTemplate>
            <Triggers>
                <asp:AsyncPostBackTrigger ControlID="Btn_RunReport" EventName="Click"></asp:AsyncPostBackTrigger>
            </Triggers>
        </asp:UpdatePanel>
    </div>
    <!-- right block end -->
<!-- main content end -->
</div>
<!-- export csv popup begins -->
<asp:Panel ID="Panel_ExportCSV" runat="server" Width="300" CssClass="popupPanel">
<div id="exportCSVPopup" class="yesNoAlert">
    <strong>
        <span>Export Report</span>
        <a href="#" class="close">Close</a>
    </strong>
    <div class="inner">
	    <a id="exportCSVLink" href="#">Download Word File</a>
	    <br />
    </div>
</div>
</asp:Panel>
<cc2:DragOverlayExtender ID="DragOverlayExtender_ExportCSV" TargetControlID="Panel_ExportCSV" runat="server" Enabled="true" />
<cc1:DropShadowExtender ID="DropShadowExtender_ExportCSV" runat="server"
    TargetControlID="Panel_ExportCSV" 
    Rounded="false"
    Width="5"
    Opacity="0.25" 
    TrackPosition="true"  />
<!-- export csv popup ends -->
<script type="text/javascript">
    
    function loadAssetSearchFields () {
        // make calls to load search params                           
        var sProc = "<STOREDPROCEDURE Name=\"sproc_WEB_GetSearchFields\" Level=\"4\" />";
        callAjaxPost(comboSFRequest, sProc, processComboSFRequestChange);   
    }
    activeEditorPageId = "reportTasks";
    loadAssetSearchFields();
    
    // function to prepare search
	var assetSearchRequest = null;
	function prepareSearch() {
	    assetSearchRequest = new XMLHttpRequest();
        
        // add values to search xml
        addSearchValuesToXML();  

        var url = "ListSearchPost.aspx";
        assetSearchRequest.open('POST', url, false);
        assetSearchRequest.setRequestHeader("Content-Type", "text/xml");
        assetSearchRequest.send(sfXML);
        if (assetSearchRequest.readyState == 4) {
		    if (assetSearchRequest.status == 200) {
		        return;
		    }
		}
	}
	
	function showExportPopup() {
	    var filePath = "Exports" + "\/" + "<%= ExportFileName.Value %>";
        $('exportCSVLink').setAttribute('href', filePath);
        $('exportCSVPopup').style.display = "block";
    }
    
    function showProgress() {
        var msgLabel = $('<%= Lbl_Messages.ClientID %>');
        if (msgLabel) {
            msgLabel.text = "Please wait.  Attempting to retrieve report results...";
            msgLabel.style.display = "block";
        }
    }    
</script>
</form>

</asp:Content>

